package com.teach.demo.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/demo/log")
@Slf4j
public class LogController {

  // public static final Logger log = LoggerFactory.getLogger(LogController.class);//等价: @Slf4j
  
  @GetMapping
  public Object log(){
    log.trace("跟踪日志");
    log.debug("调试日志");
    log.info("信息日志");
    log.warn("警告日志");
    log.error("错误日志");
    try{
      int i = 1/0;
      log.debug("i={}",i);
    }catch(Exception ex){
      log.warn("数学计算异常",ex);
    }
    return null;
  }
}
